<?php

use think\migration\Migrator;
use app\model\CouponBrand;

class AlterCouponBrandInsertSomething extends Migrator
{
    public function up()
    {
        $jutuikeBrands = [
            ///////出行加油//////
            47 => ['act_name' => '高德打车CPS+CPA拉新', 'serv_type' => PRODUCT_TRAVEL_OIL_SERV, 'short_name' => '高德打车', 'type' => 'travel', 'image_url' => 'https://s1.ax1x.com/2022/04/23/LfKkPH.png'],//高德
            43 => ['act_name' => '滴滴加油CPS活动', 'serv_type' => PRODUCT_TRAVEL_OIL_SERV, 'short_name' => '滴滴加油', 'type' => 'travel', 'image_url' => 'https://s1.ax1x.com/2022/04/23/LfKiIe.png'],//出行，加油
            87 => ['act_name' => '同程打车CPS+CPA拉新', 'serv_type' => PRODUCT_TRAVEL_OIL_SERV, 'short_name' => '同程打车', 'type' => 'travel', 'image_url' => 'https://s1.ax1x.com/2022/08/23/v6zydI.png'],//同程打车
            49 => ['act_name' => '花小猪打车CPS+CPA拉新', 'serv_type' => PRODUCT_TRAVEL_OIL_SERV, 'short_name' => '花小猪打车', 'type' => 'travel', 'image_url' => 'https://s1.ax1x.com/2022/04/23/LfKVxI.png'],//花小猪
            42 => ['act_name' => '滴滴打车CPS活动', 'serv_type' => PRODUCT_TRAVEL_OIL_SERV, 'short_name' => '滴滴打车', 'type' => 'travel', 'image_url' => 'https://s1.ax1x.com/2022/04/23/LfKCVO.png'],//滴滴加油
            44 => ['act_name' => '滴滴货运CPA活动', 'serv_type' => PRODUCT_TRAVEL_OIL_SERV, 'short_name' => '滴滴货运', 'type' => 'travel', 'image_url' => 'https://s1.ax1x.com/2022/04/23/LfKPaD.png'],//货运
            67 => ['act_name' => '滴滴有车(加油/代驾)', 'serv_type' => PRODUCT_TRAVEL_OIL_SERV, 'short_name' => '滴滴代驾', 'type' => 'travel', 'image_url' => 'https://s1.ax1x.com/2022/04/23/LfKpqK.png'],//滴滴有车
            ///////连锁餐饮/////
            46 => ['act_name' => '汉堡王在线点餐', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '汉堡王', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKnt1.png'],//汉堡王
            34 => ['act_name' => '星巴克在线点餐', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '星巴克', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKZ79.png'], //星巴克
            26 => ['act_name' => '麦当劳在线点餐CPS', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '麦当劳', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKkXF.png'], //麦当劳
            16 => ['act_name' => '肯德基在线点餐CPS', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '肯德基', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKV0J.png'], //肯德基
            31 => ['act_name' => '百果园水果外送', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '百果园', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKmkR.png'], //百果园
            32 => ['act_name' => '奈雪的茶在线点餐', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '奈雪的茶', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKEm4.png'], //奈雪的茶
            33 => ['act_name' => '瑞幸咖啡在线点餐', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '瑞幸咖啡', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKF6U.png'], //瑞幸咖啡
            37 => ['act_name' => '喜茶在线点餐', 'serv_type' => PRODUCT_FOOD_SHOP_SERV, 'short_name' => '喜茶', 'type' => 'union_food', 'image_url' => 'https://s1.ax1x.com/2022/05/07/OMKilT.png'], //喜茶
        ];
        foreach ($jutuikeBrands as $act_id => $brand) {
            CouponBrand::findOrCreate([
                'name'      => $brand['short_name'],
                'image_url' => $brand['image_url'],
                'icon'      => $brand['image_url'],
                'belong'    => CouponBrand::BELONG_JUTUIKE,
                'act_id'    => $act_id,
                'act_name'  => $brand['act_name'],
                'type'      => $brand['type'],
                'serv_type' => $brand['serv_type'],
            ]);
        }
    }

    public function down()
    {
        CouponBrand::destroy(function($query){
            $query->where('belong',CouponBrand::BELONG_JUTUIKE);
        });
    }
}
